package com.j2eefast.flowable.erp.service;


import com.j2eefast.flowable.erp.entity.bpmErpPersonPaybackEntity;
import com.j2eefast.flowable.erp.mapper.bpmErpPersonPaybackMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * ERP人事还款流程Service接口
 * @author: yhli
 * @date 2020-07-21 10:05
 */
@Service
public class bpmErpPersonPaybackService extends ServiceImpl<bpmErpPersonPaybackMapper,bpmErpPersonPaybackEntity> {

	@Resource
	private bpmErpPersonPaybackMapper bpmErpPersonPaybackMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmErpPersonPaybackEntity> queryWrapper = new QueryWrapper<bpmErpPersonPaybackEntity>();
           String serialNumber = (String) params.get("serialNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(serialNumber), "serial_number", serialNumber);
                                  String applyBeneficiaryUsername = (String) params.get("applyBeneficiaryUsername");
        queryWrapper.like(ToolUtil.isNotEmpty(applyBeneficiaryUsername), "apply_beneficiary_username", applyBeneficiaryUsername);
             String applyEnterAmount = (String) params.get("applyEnterAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(applyEnterAmount), "apply_enter_amount", applyEnterAmount);
          String applyPaybackMethod = (String) params.get("applyPaybackMethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(applyPaybackMethod), "apply_payback_method", applyPaybackMethod);
          String applyBankBalance = (String) params.get("applyBankBalance");
         queryWrapper.eq(ToolUtil.isNotEmpty(applyBankBalance), "apply_bank_balance", applyBankBalance);
          String applyPaymentMethod = (String) params.get("applyPaymentMethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(applyPaymentMethod), "apply_payment_method", applyPaymentMethod);
                      String approvalReview = (String) params.get("approvalReview");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalReview), "approval_review", approvalReview);
             String approvalReceivedAmount = (String) params.get("approvalReceivedAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalReceivedAmount), "approval_received_amount", approvalReceivedAmount);
             String approvalReceiptno = (String) params.get("approvalReceiptno");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalReceiptno), "approval_receiptno", approvalReceiptno);
              		Page<bpmErpPersonPaybackEntity> page = bpmErpPersonPaybackMapper.selectPage(new Query<bpmErpPersonPaybackEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmErpPersonPaybackEntity bpmErpPersonPaybackEntity) {
		Page<bpmErpPersonPaybackEntity> page = bpmErpPersonPaybackMapper.findPage(new Query<bpmErpPersonPaybackEntity>(params).getPage(), bpmErpPersonPaybackEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmErpPersonPaybackByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmErpPersonPaybackById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmErpPersonPayback(bpmErpPersonPaybackEntity bpmErpPersonPayback){
        return save(bpmErpPersonPayback);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmErpPersonPaybackById(bpmErpPersonPaybackEntity bpmErpPersonPayback) {
		return updateById(bpmErpPersonPayback);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmErpPersonPaybackEntity getbpmErpPersonPaybackById(String id){
		return getById(id);
	}
}
